/**
 * 
 */
package com.datetime;

import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * @author ChengNing
 * @date   2012-9-5
 */
public class DateTime {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Date now = new Date();
		SimpleDateFormat dateFormater = new SimpleDateFormat("yy-MM-dd");
		String shortYear = dateFormater.format(now);
		
		System.out.println(shortYear);
		
		DateTime dtDateTime = new DateTime();
		dtDateTime.PrintTime();

	}
	
	/**
	 * format date
	 * @param date
	 * @param formatString
	 * @return
	 */
	public String format(Date date,String formatString) {
		SimpleDateFormat dateFormater = new SimpleDateFormat(formatString);
		return dateFormater.format(date);
	}
	
	public void PrintTime(){
		long s = System.currentTimeMillis();
		PrintTime(1);
		long s1 = System.currentTimeMillis();		
		PrintTime(10);
		long s2 = System.currentTimeMillis();
		PrintTime(100);
		long s3 = System.currentTimeMillis();
		PrintTime(1000);
		long s4 = System.currentTimeMillis();
		PrintTime(10000);
		long s5 = System.currentTimeMillis();
		PrintTime(100000);
		long s6 = System.currentTimeMillis();
		
		System.out.println("1 times print cost:" + (s1-s));
		System.out.println("10 times print cost:" + (s2-s1));
		System.out.println("100 times print cost:" + (s3-s2));
		System.out.println("1000 times print cost:" + (s4-s3));
		System.out.println("10000 times print cost:" + (s5-s4));
		System.out.println("100000 times print cost:" + (s6-s5));
		
	}
	
	public static void PrintTime(int times){
		for(int i=0;i<times;i++)
		{
			System.out.println("cedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjlcedkfjdlfkjdfkdfjldkjsl;kfsdjfhdklfjl");
		}
	}

}
